BEGIN;

CREATE OR REPLACE VIEW win_observation_textual_data_with_ecosystem_view AS
  select win_observation_textual_data_view.*, ecosystem_id from win_observation_textual_data_view, win_observations where win_observation_textual_data_view.id = win_observations.id;

DROP VIEW win_observation_statistics_view ;

CREATE OR REPLACE VIEW win_observation_statistics_view AS 
 SELECT ( SELECT count(drupal_users.uid) AS count
           FROM drupal_users
          WHERE drupal_users.uid > 1) AS num_contributors, ( SELECT count(DISTINCT drupal_profile_values.value) AS count
           FROM drupal_profile_values
          WHERE drupal_profile_values.fid::integer = (( SELECT drupal_profile_fields.fid
                   FROM drupal_profile_fields
                  WHERE drupal_profile_fields.name::text = 'profile_country'::text))) AS num_contributor_countries, ( SELECT count(win_observations.id) AS count
           FROM win_observations) AS num_contributions, ( SELECT count(DISTINCT win_validation.observation_id) AS count
           FROM win_validation where win_validation.status = 1) AS num_validated_contributions;

COMMIT;